<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信登陆页面</title>
</head>
<body>

<img src="" id="loginImg">
<button id="loginBtn">获取登陆二维码</button>
<input type="text" id="loginID" readonly>
<input type="text" name="key_content" id="key" style="display: none;height: 30px;width: 600px;">
<button id="submitBtn" style="display: none;">提交关键字</button>


<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
//    获取登陆二维码
    $("#loginBtn").click(function () {
        $("#loginBtn").attr("disabled","disabled")
        $.ajax({
            url:"/getImg",
            async:true,
            error:function () {
                alert("服务器出错")
            },
            success:function (data) {
                console.log("success")
                console.log(data.toString())
                var dataStr = data.toString()
                var arr = dataStr.split("&")
                $("#loginImg").attr("src",arr[0])
                $("#loginID").val(arr[1])
                $("#key").css("display","block")
                $("#submitBtn").css("display","block")
            }
            });
    });
//提交关键字
    $("#submitBtn").click(function () {
        $("#submitBtn").attr("disabled","disabled")
        loginID = $("#loginID").val()
        key = $("#key").val()
        $.ajax({
            url:"/submitKey",
            type:"POST",
            data:{"key":key,"loginID":loginID},
            async:true,
            error:function () {
                alert("服务器出错")
            },
            success:function (data) {
                console.log("success")
                if(data == "success"){
                    alert("内容提交成功")
                }else {
                    alert("系统检测您没有登陆")
                }
            }
            });
    });



</script>
</body>
</html>